#ifndef FND_GAME_2D_ACTOR_HPP
#define FND_GAME_2D_ACTOR_HPP
#include "indexresource.hpp"
#include <sfml/system.hpp>
#include <sfml/graphics/rect.hpp>
#include <box2d.h>
#include <boost/tuple/tuple.hpp>
#include <set>
#include "message.hpp"
#include "actor_creater.hpp"
#include "drawer.hpp"
#include <sfml/graphics.hpp>

namespace FndGame2D {

  class actor : public drawer {
  public:
    typedef index_resource_manager<sf::IntRect>::key_type key_type ;
    typedef sf::IntRect rect_type ;
    typedef sf::Vector2<float> position_type ;              
    // actor_msg_functioner message_handler ;
    // actor_updater_functioner updater ;
    static const std::string ADD_FIRENDS_OR_ENEMYS ;
    static const std::string REMOVE_FIRENDS_OR_ENEMYS ;
    static const std::string MSG_FOR_ALL_FOE ; // FOE friends or enemys
    explicit actor(const std::string& name = std::string() ) ;
  private:
    sf::Sprite* m_sprite ;
    b2Body* m_physics ;
    key_type m_key ;
    std::set<std::string> m_assoicate_actors ;
  protected:
    void actor_defalut_render(sf::RenderTarget& w) ;
  public:
    //actor_render_type renderer ;
   
    void create_physics_obj(b2World& world, const b2BodyDef& body_def,
			    b2ShapeDef* shape) ;
    void set_image(const sf::Image& img) ;
    //void render(sf::RenderTarget& window) {renderer(window);}
    void add_rect(const sf::IntRect& rect) {m_mgr.add_value(rect);}
    void push_index(const key_type& key,
		    std::size_t index) {
      m_mgr.add_index(key, index) ;
    }
    void push_index(std::size_t index) {
      push_index(m_key, index) ;
    }
    void change_rect(const key_type& key, std::size_t index) ;
    const rect_type get_bounding() const ;
    const position_type& get_postion() const ;
    float get_x()const {return get_postion().x ;}
    float get_y()const {return get_postion().y ;}
    void set_position(float x, float y) ;
    void set_center(float x, float y) ;
    position_type get_physics_position() const ;
    void set_physics_position(float x, float y) ;
    float get_angle() const ;
    float get_physics_angle() const ;
    void set_angle(float angle_in_rand) ;
    void set_physics_angle(float angle_in_rand) ;
    void fix_position_use_physics() ;
    void fix_rotation_use_physics() ;
   
    void change_rect(std::size_t index) {
      change_rect(m_key,index) ;
    }
    void set_current_index_group(const key_type& key) {
      m_key = key ;
      change_rect(0) ;
    }
    const key_type& get_current_index_group() const {
      return m_key ;
    }


  public:
    index_resource_manager<sf::IntRect>  m_mgr ;
    //actor() : m_sprite(0) {}
     ~actor() ;
  } ;
 
}
#endif
